#include "Shape.h"


Shape::Shape(void)
{
	
}

Shape::~Shape(void)
{
}


M3DPoint getVertex(const M3DPoint &p1, const M3DPoint &p2) {
	M3DPoint v;
	v.point[0] = p2.point[0]-p1.point[0];
	v.point[1] = p2.point[1]-p1.point[1];
	v.point[2] = p2.point[2]-p1.point[2];
	return v;
}

void calculateNormal(MVertex *p, const M3DPoint &v, const M3DPoint &t, 
							const M3DPoint &b, const M3DPoint &l, const M3DPoint &r) {
	MVertex n1, n2, n3, n4;
	n1 = getVertex(v,t).CrossProduct(getVertex(v,l));
	n2 = getVertex(v,r).CrossProduct(getVertex(v,t));
	n3 = getVertex(v,l).CrossProduct(getVertex(v,b));
	n4 = getVertex(v,b).CrossProduct(getVertex(v,r));
	(*p) = (n1+n2+n3+n4).normailize();
}
